//
//  LLT_WeekFreeViewController_LXM.m
//  CoderLLT
//
//  Created by 刘晓萌 on 15/12/12.
//  Copyright © 2015年 刘晓萌. All rights reserved.
//

#import "LLT_WeekFreeViewController_LXM.h"
#import "LLT_DetailOfArticleModel.h"
#import "LLT_HeroInfoViewController_LXM.h"

@interface LLT_WeekFreeViewController_LXM ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *weekFreeWebView;

@end

@implementation LLT_WeekFreeViewController_LXM

- (void)viewDidLoad {
    [super viewDidLoad];
    self.weekFreeWebView.delegate = self;
    [self.weekFreeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://static.lolmax.com/api/static/lol/pages/free/freeThisWeek.html"]]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 * uiwebView按状态响应加载
 *
 * @return
 */
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *str = [request URL].absoluteString;
    str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSString *strsub = [str substringToIndex:6];
    NSString *s = @"maxjia://PageConfigJson#/";
    if ([strsub isEqualToString:@"maxjia"]) {
        str =  [str stringByReplacingOccurrencesOfString:s withString:@""];
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding:NSUTF8StringEncoding]
                                                            options: NSJSONReadingMutableContainers
                                                              error: nil];
        
        LLT_DetailOfArticleModel *heroUrls = [[LLT_DetailOfArticleModel alloc]init];
        [heroUrls setValuesForKeysWithDictionary:dic[@"result"]];
        LLT_HeroInfoViewController_LXM *heroInfoVC = [MainStoryBoard instantiateViewControllerWithIdentifier:@"heroInfoVC"];
        heroInfoVC.heroUrls = heroUrls;
        [self presentViewController:heroInfoVC animated:YES completion:nil];
    }
    
    return YES;
}

/**
 * 设置电源栏反颜色
 *
 * @return
 */
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

/**
 * 点击左侧返回
 */
- (IBAction)didClickLeftButton:(UIButton *)sender {
    DissMissBack;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
